//Object默认是所有类的父类
//  toString：转为字符串
//  equals：比较对象
//  clone：克隆，Cloneable
//
//
//
//
//

import java.util.Objects;

class Money implements Cloneable
{
    protected double m = 19.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Person implements Cloneable
{
    public String name;
    public int age;
    public Money money = new Money();
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();
        tmp.money = (Money) this.money.clone();

        return tmp;
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj) return true;
        if(obj == null || getClass() != obj.getClass()) return false;
        Person person = (Person) obj;
        return this.age == person.age && Objects.equals(this.name, ((Person) obj).name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.name,this.age);
    }
}
public class Interface {
    public static void main(String[] args) {
        Person p1 = new Person("蛋蛋", 12);
        Person p2 = new Person("蛋蛋", 12);
        System.out.println(p1.equals(p2));
    }
}
